package com.juneng.config;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author chang
 * @create 2021/4/29 20:43
 */
@Data
public class PageResult<T> implements Serializable {

    /**
     * 当前页数
     */
    @ApiModelProperty(value = "当前页数")
    private Integer currentPage = 1;
    /**
     * 每页个数
     */
    @ApiModelProperty(value = "每页个数")
    private Integer pageSize = 10;
    /**
     * 每页的数据
     */
    @ApiModelProperty(value = "每页的数据")
    private List<T> body;
    /**
     * 总共多少条
     */
    @ApiModelProperty(value = "总共多少条")
    private Integer total = 0;

    /**
     * 总共多少页
     */
    @ApiModelProperty(value = "总共多少页")
    private Integer totalPage = 0;

    public PageResult() {

    }


    public PageResult(Integer currentPage, Integer pageSize, List<T> body, Integer total) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.body = body;
        this.total = total;
        this.totalPage = (this.total + this.pageSize - 1) / this.pageSize;
    }

    public PageResult(Integer currentPage, Integer pageSize) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
    }


}
